/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gamesync;

/**
 *
 * @author BEO
 */
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class Logger {
    public static void startLogger() {
        File logDir = new File(System.getProperty("user.home")+"\\SyncLog\\");
        // if the logging directory does not exist, create it
        if (!logDir.exists()) {
           // System.out.println("creating directory: " + directoryName);
          boolean result = logDir.mkdir();  
           if(result) {    
             //System.out.println("DIR created");  
           }
        }       
    }
    
    public static void writeClientFile(String log) {
 	try {
            PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(System.getProperty("user.home")+"\\SyncLog\\client.log", true)));
            out.println(log+"\n");
            out.close();
	} catch (IOException e) {
		//e.printStackTrace();
	}       
    }
 
    public static void writeServerFile(String log) {
 	try {
            PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(System.getProperty("user.home")+"\\SyncLog\\server.log", true)));
            out.println(log+"\n");
            out.close();
	} catch (IOException e) {
		//e.printStackTrace();
	}       
    }
        
    public static void writeClientMonitor(String log) {
        ClientMonitorFrame.LogArea.append(log+"\n");
    }
    
    public static void writeServerMonitor(String log) {
        ServerMonitorFrame.MonitorArea.append(log+"\n");
    }
    
    
}
